<?php require_once('../../core/import.php');?>
<?php User::Permission('STATISTICS_ACCOUNT'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=8" />
    <script type="text/javascript" src="../../scripts/import.js"></script>
    <script type="text/javascript" src="../../scripts/components/checkbox/import.checkbox.js"></script>
    <script type="text/javascript" src="../../scripts/components/zebra_table/import.zebra_table.js"></script>
    <SCRIPT src="scripts/setday.js"></SCRIPT>
    <script type="text/javascript" src="scripts/list.js"></script>
</head>

<body>
<?php 
	$Period=trim(Functions::HttpArgs('T_Class'));
	$UserName=trim(Functions::HttpArgs('Username'));
	if(!$UserName){ $UserName=User::Session('Username'); }
	if(!$Period) $Period=1;
?>
<form id="Form_select" name="Form_select" method="post" action="statistics.news.list.php?T_Class=<?php echo $Period;?>&Username=<?php echo $UserName?>">
    <table width="98.5%" border="0" cellpadding="0" cellspacing="0" class="List">
    <thead>
    <tr>
        <th width="8%" height="25" align="right" valign="middle">日期：&nbsp; </th>
        <th width="10%" height="25" align="left" valign="middle"><input type="text" name="Datetimes" id="Datetimes" onclick="setday(this)" size="12" /></th>
        <th width="50%" height="25" align="left" valign="middle">查询周期：
        	<input type="radio" name="T_Class" value="1" onclick="Click_Period();" <?php if($Period==1) echo 'checked';?>/> 日&nbsp;
	  		<input type="radio" name="T_Class" value="2" onclick="Click_Period();" <?php if($Period==2) echo 'checked';?>/> 周 
            <input type="radio" name="T_Class" value="3" onclick="Click_Period();" <?php if($Period==3) echo 'checked';?>/> 月 
            <input type="radio" name="T_Class" value="4" onclick="Click_Period();" <?php if($Period==4) echo 'checked';?>/> 年 
        </th>
        <th width="32%" height="25" align="left" valign="middle"><input type="submit" value="搜 索" /></th>
    </tr>
    </thead>
    </table>
    </form>
     <form id="Form1" name="Form1" method="post" action="?" >
    <table width="98.5%" id="List" border="0" cellpadding="0" cellspacing="0" class="List">
    <thead>
    <tr><td colspan="13"> &nbsp;<?php User::Sum_Count('资讯版块','Classes',NULL,NULL,$UserName); ?></td></tr>
    </thead>
    <thead>
    
    <tr>
        <th width="7%" height="25" align="center" valign="middle">资讯版块</th>
        <th width="7%" align="center" valign="middle">&nbsp;专题频道</th>
        <th width="7%" align="center" valign="middle">人物访谈</th>
        <th width="7%" align="center" valign="middle">企业之窗</th>
        <th width="7%" align="center" valign="middle">船厂订单</th>
        <th width="7%" align="center" valign="middle">行业展会</th>
        <th width="7%" align="center" valign="middle">展会专题</th>
        <th width="7%" align="center" valign="middle">会展公司</th>
        <th width="7%" align="center" valign="middle">期刊添加</th>
        <th width="7%" align="center" valign="middle">杂志添加</th>
        <th width="7%" align="center" valign="middle">幻灯片添加</th>
        <th width="12%" align="center" valign="middle">共发布</th>
        <th width="11%" align="center" valign="middle">执行日期</th>
    </tr>
    </thead>    
    <tbody>
    <?php
        #获取数据
	  $Datetimes=Functions::HttpArgs('Datetimes');
	  $Page=Functions::HttpArgs('page');
	  $Wheres=' where UserName=\''.$UserName.'\' and Classes=\'资讯版块\'';
	  if($Datetimes)
	    {
		  $Wheres=$Wheres." and Datetime='$Datetimes'";
	    }
	  switch($Period)
		{
			case 1:
				$Selects='select *,DATE_FORMAT(Datetime,\'%Y%年%m%月%d%日\') days,count(ID) countnum from statistics';
				$Period_Class='days';
				break;
			case 2:
				$Selects='select *,DATE_FORMAT(Datetime,\'%Y%年%u%周\') weeks,count(ID) countnum from statistics';
				$Period_Class='weeks';
				break;
			case 3:
				$Selects='select *,DATE_FORMAT(Datetime,\'%Y%年%m%月\') months,count(ID) countnum from statistics';
				$Period_Class='months';
				break;
			case 4:
				$Selects='select *,DATE_FORMAT(Datetime,\'%Y%年\') years,count(ID) countnum from statistics';
				$Period_Class='years';
				break;
			default:
				exit('参数错误');
		}
		$Groups=' group by '.$Period_Class.' order by '.$Period_Class.' desc ';
		$Sqls=$Selects.$Wheres.$Groups;
		$DB=DB::GetInstance();
		$pagesize = 15;//设置每页显示条数
		//echo $Sqls;
		$numrows=DB::GetRows($Sqls);
		$numrows = count($numrows);//计算总记录
		$pages = intval($numrows/$pagesize);
		if($numrows%$pagesize)$pages++;//设置页数
		if(isset($Page)){
			$page = intval($Page);
		}else{
			$page = 1;
		} //设为第一页
		$strpage=($page*$pagesize-$pagesize);
		$Sqls =$Sqls. " limit ".$strpage.",".$pagesize."";
		
		$Datas=$DB->Query($Sqls);
	
        foreach($Datas as $Row)
        {
    ?>
    <tr>
        <td height="25" align="center" valign="middle">
        <?php
        	User::Statistics_Cxecution('news','资讯版块--添加信息',$Period_Class,$Row[$Period_Class],$Selects,'news',NULL,NULL,$UserName);
		?>
        </td>
        <td height="25" align="center" valign="middle">
        <?php
        	User::Statistics_Cxecution('topic','专题频道--添加信息',$Period_Class,$Row[$Period_Class],$Selects,'news',NULL,NULL,$UserName);
		?>
        </td>
        <td height="25" align="center" valign="middle">
        <?php
        	User::Statistics_Cxecution('interview','人物访谈--添加信息',$Period_Class,$Row[$Period_Class],$Selects,'news',NULL,NULL,$UserName);
		?>
        </td>
        <td height="25" align="center" valign="middle">
        <?php
        	User::Statistics_Cxecution('enterprise','企业之窗--添加信息',$Period_Class,$Row[$Period_Class],$Selects,'news',NULL,NULL,$UserName);
		?>
        </td>
        <td height="25" align="center" valign="middle">
        <?php
        	User::Statistics_Cxecution('shipyard_ordersheet','船厂订单--添加信息',$Period_Class,$Row[$Period_Class],$Selects,'news',NULL,NULL,$UserName);
		?>
        </td>
        <td height="25" align="center" valign="middle">
        <?php
        	User::Statistics_Cxecution('exhibition_infos','行业展会--添加信息',$Period_Class,$Row[$Period_Class],$Selects,'news',NULL,NULL,$UserName);
		?>
        </td>
        <td height="25" align="center" valign="middle">
        <?php
        	User::Statistics_Cxecution('exhibition_topic','展会专题--添加信息',$Period_Class,$Row[$Period_Class],$Selects,'news',NULL,NULL,$UserName);
		?>
        </td>
        <td height="25" align="center" valign="middle">
        <?php
        	User::Statistics_Cxecution('exhibition_company','会展公司--添加信息',$Period_Class,$Row[$Period_Class],$Selects,'news',NULL,NULL,$UserName);
		?>
        </td>
        <td height="25" align="center" valign="middle">
        <?php
        	User::Statistics_Cxecution('ejournal','期刊杂志--期刊添加',$Period_Class,$Row[$Period_Class],$Selects,'news',NULL,NULL,$UserName);
		?>
        </td>
        <td height="25" align="center" valign="middle">
        <?php
        	User::Statistics_Cxecution('dm','期刊杂志--杂志添加',$Period_Class,$Row[$Period_Class],$Selects,'news',NULL,NULL,$UserName);
		?>
        </td>
        <td height="25" align="center" valign="middle">
        <?php
        	User::Statistics_Cxecution('dm_slide','期刊杂志--幻灯片添加',$Period_Class,$Row[$Period_Class],$Selects,'news',NULL,NULL,$UserName);
		?>
        </td>
        <td height="25" align="center" valign="middle">
        <?php
        	echo '共发布<font color="red">'.$Row['countnum'].'</font>条信息';
		?>
        </td>
        <td height="25" align="center" valign="middle">
            <?php echo $Row[$Period_Class];?>
        </td>
    </tr>
    <?php
        }
    ?>
    
    </tbody>    
    <tfoot>
    <tr>
        <td height="25" colspan="13" align="center" valign="middle">
            <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td width="55%" align="left">
                <?php
                  //取得当前路径
				$url = "statistics.news.list.php?T_Class=$Period&Username=$UserName";
				$first=1;
				$prev=$page-1;
				$next=$page+1;
				$last=$pages;
				if($page==1&&$pages>1)
				{
				echo "[首页]&nbsp;";
				echo "[上一页]&nbsp;";
				echo "<a href=\"".$url."&page=".$next."\"><font color='#666666'>[下一页]</font></a>&nbsp;";
				echo "<a href=\"".$url."&page=".$last."\"><font color='#666666'>[尾页]</font></a>&nbsp;";
				}
				elseif($page>=1&&$page!=$pages&&$numrows>0)
				{
				echo "<a href=\"".$url."&page=".$first."\"><font color='#666666'>[首页]</font></a>&nbsp;";
				echo "<a href=\"".$url."&page=".$prev."\"><font color='#666666'>[上一页]</font></a>&nbsp;";
				echo "<a href=\"".$url."&page=".$next."\"><font color='#666666'>[下一页]</font></a>&nbsp;";
				echo "<a href=\"".$url."&page=".$last."\"><font color='#666666'>[尾页]</font></a>&nbsp;";
				}
				elseif($page==$pages&&$page!=1)
				{
				echo "<a href=\"".$url."&page=".$first."\"><font color='#666666'>[首页]</font></a>&nbsp;";
				echo "<a href=\"".$url."&page=".$prev."\"><font color='#666666'>[上一页]</font></a>&nbsp;";
				echo "[下一页]&nbsp;";
				echo "[尾页]&nbsp;";
				
				}
				elseif($page==$pages)
				{
				echo "[首页]&nbsp;";
				echo "[上一页]&nbsp;";
				echo "[下一页]&nbsp;";
				echo "[尾页]&nbsp;"; 
				}
				else
				{
				echo "[首页]&nbsp;";
				echo "[上一页]&nbsp;";
				echo "[下一页]&nbsp;";
				echo "[尾页]&nbsp;";
				}
				?>
                        页次<span><?php echo $page."/".$pages ?></span>页 共<span><?php echo $numrows ?></span>条 <?php echo $pagesize."条/每页" ?>
                </td>
            </tr>
            </table>    
         </td>
	</tr>
    </tfoot>    
    </table>
    </form>
</body>
</html>